<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>机构部门树</title>
		<link type="text/css" rel="stylesheet" href="<%=basePath%><s:property value="#session.themeStyle.mainCss" default="Skin/PM/LightBlue/main.css"/>" />
		<link rel="stylesheet" href="<%=basePath %>css/zTreeStyle/zTreeStyle.css" type="text/css" />
		<script type="text/javascript" src="<%=basePath %>js/jquery.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/ztree/jquery.ztree.core-3.5.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/ztree/jquery.ztree.excheck-3.5.js"></script>
		<style type="text/css">
				.buttonLab{
					cursor: pointer;
					background-image: url('<%=basePath%>images/main/button_bg.png');
					width: 80px; 
					height: 22px;
					color:white;
				}
			</style>
<style type="text/css">
	</style>
		<script type="text/javascript">
			var setting = {
				check: {
					enable: true
				},
				data: {
					simpleData: {
						enable: true
					}
				}
			};


		var zNodes =<s:property value="orgInfoJson" escape="false"/>;

		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		});
		function addDept(){
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
            var nodes = zTree.getCheckedNodes(true);
            var purview = "";
            for (var i = 0; i < nodes.length; i++) {
				if(!nodes[i].getCheckStatus().half){
					if(nodes[i].id!=undefined){
						if(purview==""){
							//purview = nodes[i].id+"|"+nodes[i].name;
							purview ="{\"id\":\""+ nodes[i].id+"\",\"name\":\""+nodes[i].name+"\"}";
						}else{
							//purview +="," + nodes[i].id+"|"+nodes[i].name;
							purview +=",{\"id\":\""+ nodes[i].id+"\",\"name\":\""+nodes[i].name+"\"}";
						}
					}
				}
            }
            purview ="["+purview+"]";
            window.returnValue=purview;
    		window.close();
		}
		</script>
	</head>
<body style="background-color: #fff;">
	<div style="height: 30px;margin-top: 5px;border-bottom: #3497cf 1px solid;" align="center"><a class="but28"  onclick="addDept();" >确定</a></div>
	<div id="orgTree" >
		<ul id="treeDemo" class="ztree"></ul>
	</div>
</body>
</html>